<script type="text/javascript" charset="utf-8">
$(function() {

	//jquery slideUp
	$("fieldset.expansible legend").click(function () {
	      if ($(this).siblings().is(":hidden")) {
	        $(this).siblings().show("slow").end().removeClass("toggle-close").addClass("toggle-open").parent().removeClass("noborder");
	      } else { //close
	        $(this).siblings().slideUp().end().removeClass("toggle-open").addClass("toggle-close").parent().addClass("noborder");
	      }
	    });
	 $("fieldset.expansible legend").addClass("toggle-open");
	
	$("tr.account_type").hide();
	$("tr.credit").hide();
	$("tr.bank").hide();
	$("#payment_method").change(function(){
		if($(this).val() == 'creditcard')
			$("tr.account_type").show();
		else
		{
			$("tr.account_type").hide();
			$("tr.credit").hide();
		}
		
		if($(this).val() == 'atm')
			$("tr.bank").show();
		else
			$("tr.bank").hide();
	});
	
	$("#account_type").change(function(){
		if($(this).val() == 'visa' || $(this).val() == 'masterCard' || $(this).val() == 'AmericanExpress' 
			|| $(this).val() == 'DinnerClub' || $(this).val() == 'JCB')
			$("tr.credit").show();
		else
			$("tr.credit").hide();
	});
	
	if($("#payment_method").val() != 'none')
		$("tr.account_type").show();
	if('<?=$this->account_type?>' != 'none')
		$("tr.credit").show();
});
</script>

<div class="success-message"><?=$this->successMessage; ?></div>
<div class="error-message"><?=$this->errorMessage; ?></div>

<?if ($this->justRegistered == 1) :?>
<?=t(447) ?>
<?endif ?>

<?if($this->mode != 'edit-billing' && isset($this->dataDisplay)) :?>
<fieldset class="expansible"><legend id="current-billing"><span><?=t(1013) ?></span></legend>
<? foreach ($this->dataDisplay as $k => $v) :?>
    <div style="border:1px solid #d8d9d9;margin-left:20px">
    	<?if(isset($v['profileName'])) :?><h3><?=t(500)?>:<?=$v['profileName']?></h3><?endif?><br/>
        <?if(isset($v['address'])) :?><b><?=t(499)?>:</b><?=$v['address'] ?> <?endif?>
        <?if(isset($v['payment_method'])) :?><b><?=t(785)?>:</b><?=$v['payment_method'] ?> <br/><?endif?> 
        <?if(isset($v['account_type'])) :?><b><?=t(483)?>:</b><?=$v['account_type'] ?> 
        	<?if($v['account_type'] == 'visa') :?>
       			<img src="/public/themes/prime/images/users/visa.jpeg" width="50px" height="25px"/>
       		<?elseif($v['account_type'] == 'masterCard'):?>
       			<img src="/public/themes/prime/images/users/matercard.jpeg" width="50px" height="25px"/>
       		<?elseif($v['account_type'] == 'AmericanExpress') :?>
       			<img src="/public/themes/prime/images/users/american_express.jpeg" width="50px" height="50px"/>
       		<?elseif($v['account_type'] == 'DinnerClub') :?>
       			<img src="/public/themes/prime/images/users/dca_stacked.jpg" width="50px" height="25px"/>
       		<?elseif($v['account_type'] == 'JCB') :?>
       			<img src="/public/themes/prime/images/users/JCB-Card3.jpg" width="50px" height="25px"/>
        	<?endif?>
        <br/>
        <?endif?>
        <?if(isset($v['expiry_date'])) :?><b><?=t(1011)?>:</b><?=$v['expiry_date'] ?> <br/><?endif?> 
        <?if(isset($v['verification_code'])) :?><b><?=t(1012)?>:</b><?=$v['verification_code'] ?> <br/><?endif?> 
        <?if(isset($v['account_name'])) :?><b><?=t(501)?>:</b><?=$v['account_name'] ?> <br/><?endif?>
        <?if(isset($v['account_number'])) :?><b><?=t(1010)?>:</b><?=$v['account_number'] ?> <br/><?endif?>
        <div style="text-align:right;background:#eee"> 
        	<a href="<?= $this->hvnUrl(array('action' => 'billing-info'), 'account') ?>?id=<?=$this->id?>&number=<?=$k?>">
            <?=t(38) ?></a>
            <a href="<?= $this->hvnUrl(array('action' => 'delete-billing-info'), 'account') ?>?id=<?=$this->id?>&number=<?=$k?>">
            delete</a>
        </div>
    </div>
<?endforeach ?>
</fieldset>
<?endif?>
<form accept-charset="UTF-8" action="<?= $this->escape($this->form->getAction()) ?>"
      method="<?= $this->escape($this->form->getMethod()) ?>">
<?=$this->form->overallError; ?>
<fieldset class="expansible">
<legend><span><?=t(485)?></span></legend>
<table>
<tr>
<td width="130px"> <?=t(500) ?>:</td>
<td><?= $this->form->billingProfileName; ?></td>
</tr>

<tr>
<td  width="130px"><?=t(499) ?>:</td>
<td><?= $this->form->billingAddress; ?></td>
</tr>

<tr>
<td  width="130px"><?=t(785) ?>:</td>
<td><?= $this->form->payment_method; ?></td>
</tr>

<tr class="account_type">
<td width="130px"><?=t(478) ?>:</td>
<td><?= $this->form->account_type; ?></td>
</tr>

<tr class="credit">
<td width="130px"><?=t(1011) ?>:</td>
<td><?= $this->form->expiry_date; ?></td>
</tr>
<tr class="credit">
<td width="130px"><?=t(1012) ?>:</td>
<td><?= $this->form->verificationCode; ?></td>
</tr>

<tr class="bank">
<td width="130px"><?=t(498) ?>:</td>
<td><?= $this->form->bank; ?></td>
</tr>

<tr>
<td width="130px"><?=t(501) ?>:</td>
<td><?= $this->form->account_name; ?></td>
</tr>

<tr>
<td width="130px"><?=t(1010) ?>:</td>
<td><?= $this->form->account_number; ?></td>
</tr>
</table>
<?= $this->form->submit ?>
</fieldset>
</form>
<div style="min-height:20px"></div>